package cloud.shyidong.core.util;

import java.util.Random;

/**
 * @Description TODO
 * @Author syd
 * @Date 2023/3/27
 */
public final class StringUtils {
    
    private static final String string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    
    public static boolean isEmpty(String s) {
        if (s == null) {
            return true;
        }
        if (s.trim().length() == 0) {
            return true;
        }
        return false;
    }
    
    public static boolean isNotEmpty(String s) {
        return !isEmpty(s);
    }
    
    public static String getOutTradeNo() {
        char[] result = new char[32];
        int length = string.length();
        for (int i = 0; i < 32; i++) {
            int x = new Random().nextInt(length);
            result[i] = string.charAt(x);
        }
        return new String(result);
    }
    
    public static boolean isMaxLength(String s, int maxLength) {
        if (isEmpty(s)) {
            return true;
        }
        if (s.length() > maxLength) {
            return true;
        }
        return false;
    }
    
    public static boolean isMinLength(String s, int minLength) {
        if (isEmpty(s)) {
            return true;
        }
        if (s.length() < minLength) {
            return true;
        }
        return false;
    }
    
}
